<!-- 顶部 -->
<div class="head">
    <div class="top-nav">
        <div class="main">
            <div class="left">
                <span>您好，欢迎来到木投网！</span>
                @if(session_get(UserEnum::USER_INFO_SESSION_KEY))
                    <?php $cart_info = ShopService::instance()->ShopCartList();
                    $cart_count = count($cart_info);?>

                        <!-- 登录后 -->
                <span class="login-after">
                    您好，{{session_get(UserEnum::USER_INFO_SESSION_KEY)->user_name}}（{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,0,3)}}****{{substr(session_get(UserEnum::USER_INFO_SESSION_KEY)->mobile,7)}}）
                    <a href="/logout">退出</a>
                </span>
                @else
                        <!-- 未登录 -->
                <a href="/login" class="a-login">请登录</a>
                @endif
                <a href="/register" class="a-register">免费注册</a>
            </div>
            <div class="right">
                <ul>
                    <li><a href="/user_account">我的木投网</a><span>|</span></li>
                    <li><a href="/user_order?status=0">我的订单</a><span>|</span></li>
                    <li><a href="javascript:;">在线客服</a><span>|</span></li>
                    <li><span class="last">客服热线：400-036-7917</span></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="top">
        <div class="main">
            <div class="logo left">
                <a href="/"><img src="/resource/img/logo.png" alt=""></a>
            </div>
            <div class="form left">
                <ul class="form-ul">
                    <li class="active">
                        <label for="top1">商城</label>
                        <input type="radio" name="top" value="1" id="top1" checked/>
                    </li>
                    <li>
                        <label for="top2">现货</label>
                        <input type="radio" name="top" value="2" id="top2">
                    </li>
                </ul>
                <form action="/shopping">
                    <input type="text" name="key_word"  placeholder="请搜索您所需的商品，如松木" class="form-input">
                    <button type="submit">搜索</button>
                </form>
                <form action="/new_resource">
                    <input type="text" name="key_word"  placeholder="请搜索您所需的商品，如松木" class="form-input">
                    <button type="submit">搜索</button>
                </form>
            </div>
            <div class="right shopping">
                <i class="shop-ico"></i>
                <a href="javascript:;">我的购物车 &#62</a>
                @if(session_get(UserEnum::USER_INFO_USER_ID))
                    @if(!empty($cart_info))
                <span class="num">{{$cart_count}}</span>
                <div class="shopping-info">
                    @foreach($cart_info as $v)
                    <div class="shop-box">
                        <a href="/shopping_details?product_id={{$v->product_id}}" class="shop-img"><img src="{{$v->product_img}}" alt=""></a>
                        <a href="/shopping_details?product_id={{$v->product_id}}" class="shop-name">{{$v->product_name}} {{$v->spec_name}}</a>
                        <div class="shop-num">
                            <span>￥{{$v->price}}</span>
                            <i>×{{$v->number}}</i><br/>
                            <a href="/head_cart_delete?cart_id={{$v->cart_id}}">删除</a>
                        </div>
                    </div>
                    @endforeach
                    <div class="shopping-num">
                        <span>共{{$cart_count}}件商品</span>  <span>商品总价：￥19200.00</span>
                        <a href="/shop_cart_list">去购物车</a>
                    </div>
                </div>
                    @else
                            <!-- 无商品 -->
                         <div class="shopping-info">
                            <p>
                                <i></i>
                                购物车还没有商品,赶紧选购吧!
                            </p>
                        </div>
                        <!-- 有商品 -->
                    @endif
                    @else
                            <!-- 无商品 -->
                   <div class="shopping-info">
                        <p>
                            <i></i>
                            购物车还没有商品,赶紧选购吧!
                        </p>
                    </div>
                    <!-- 有商品 -->
                    @endif
            </div>
        </div>
    </div>
</div>
<!-- 导航 -->
<div class="nav">
    <div class="main">
        <div class="nav-all left" rel="show">
            <div class="all-tit">
                <i></i>
                <a href="javascript:;">商品分类</a>
                <span></span>
            </div>
            <div class="all-wrap">
                <ul>
                    @foreach(Cache::get('cache_cate') as $k=>$v)
                    <li class="wrap-list list-{{$k+1}}">
                        <div class="list-t">
                            <a href="/shopping?category={{$v['id']}}">
                                <i></i>
                                <span>{{$v['name']}}</span>
                                <span class="right">&#62</span>
                            </a>
                        </div>
                        <div class="list-con">
                            @for($i=0;$i<=4;$i++)
                            <a href="/shopping?key_word={{$v['classes'][$i]['name']}}">{{$v['classes'][$i]['name']}}</a>
                             @endfor
                        </div>
                        <div class="list-right">
                            @for($i=0;$i<count($v['classes']);$i++)
                                <a href="/shopping?key_word={{$v['classes'][$i]['name']}}">{{$v['classes'][$i]['name']}}</a>
                            @endfor
                        </div>
                    </li>
                    @endforeach

                </ul>
            </div>
        </div>
        <div class="nav-ul left">
            <ul>
                <li class="active"><a href="/">首页</a></li>
                <li><a href="/shopping">商城</a></li>
                <li><a href="/new_resource">现货资源</a></li>
                <li><a href="/select_purchase">采购信息</a></li>
                <li><a href="/information_list?cate=100">资讯行情</a></li>
                <li><a href="javascript:;">采购保障</a></li>
                <li><a href="javascript:;">手机客户端</a></li>
            </ul>
        </div>
    </div>
</div>
<!-- 弹窗 -->
<div class="popup"></div>
<!-- 登录窗口 -->
<div class="popup-login">
    <div class="popup-bg">
        <div class="login-tit">
            会员登录
            <div class="login-close"></div>
        </div>
        <form action="/verify_login" class="form" onsubmit="return check_all()" method="post">
            <div class="form-group">
                <label for="">手机号</label>
                <input type="text" name = 'username' class="form-control" id="username">
                <i class="i i-tel"></i>
            </div>
            <div class="form-group">
                <label for="">密码</label>
                <input type="password" class="form-control" name="password" id="pwd">
                <i class="i i-pass"></i>
                <a href="/retrieve_pass">找回密码</a>
                <span id="t_pwd">手机号或密码错误</span>
            </div>
            <div class="form-group form-left">
                <input type="checkbox" checked> 自动登录
            </div>
            <div class="form-group">
                <button type="submit" class="btn-login">登&#160&#160&#160录</button>
                <a href="/register" class="a-resgin">免费注册</a>
            </div>
        </form>
    </div>
</div>
<script src="/resource/js/jquery-1.11.3.min.js"></script>
<script>

    function check_all()
    {
        var pwd	= $('#pwd').val()
        var username = $('#username').val();
        $("#t_pwd").show();
        var status = false;
        if(pwd) {
            document.getElementById('t_pwd').innerHTML = '';
            if (username) {
                var ajax = new XMLHttpRequest();
                ajax.onreadystatechange = function () {
                    if (ajax.readyState == 4) {
                        if (ajax.responseText == 0) {
                            $("#t_pwd").html("用户名或密码密码有误");
                        }else if(ajax.responseText == 2){
                            document.getElementById("t_pwd").innerHTML = '密码错误次数过多,请10分钟后登录';
                        }else if(ajax.responseText == 1){
                            $("#t_pwd").hide();
                            status = true;
                        }

                    }
                }
                //与服务器建立连接
                ajax.open('post', '/js_verify_login', false);
                ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                ajax.send('username=' + username + "&pwd=" + pwd);
                return status;
            }
        }
        return status
    }
</script>
